package com.lkd.handler;

import com.lkd.business.MsgHandler;
import com.lkd.config.TopicConfig;
import com.lkd.contract.SupplyContract;
import com.lkd.emq.Topic;
import com.lkd.service.ChannelService;
import com.lkd.service.VendingMachineService;
import com.lkd.service.VendoutRunningService;
import com.lkd.utils.JsonUtil;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.signature.qual.SignatureUnknown;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
@Slf4j
@Topic(TopicConfig.TASK_SUPPLY_TOPIC)
public class SupplyCompleteHandler implements MsgHandler {


    @Autowired
    private VendingMachineService vendingMachineService ;

    /**
     * 补货工单完成后更新售货机货道信息
     * @param jsonMsg
     * @throws IOException
     */
    @Override
    public void process(String jsonMsg) throws IOException {
        log.info("接收到消息:{}",jsonMsg);
        //解析数据
        SupplyContract contract = JsonUtil.getByJson(jsonMsg, SupplyContract.class);
        //更新售货机状态
        vendingMachineService.updateVendingMachine(contract);
    }
}


























